<?php

namespace App\Jobs;

use App\Business\DataLog\LogBase;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class LogQueue implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $log;

    /**
     * LogQueue constructor.
     * @param LogBase $log 记录日志的队列
     */
    public function __construct(LogBase $log)
    {
        $log->InstializeStart();
        $this->log=$log;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $this->log->Insert();
        $this->log=null;
    }
}
